package com.yuwen.service.impl;

import com.yuwen.dao.UserDao;
import com.yuwen.pojo.Users;
import org.apache.tomcat.jni.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserService {
    @Resource
    private UserDao userDao;

    public void save(Users users){//add,update调用的都是save方法，所以合并一个，springboot能自动区分添加还是修改（只是一个id区别）
        userDao.save(users);
    }

    public void del(Integer uid){
        userDao.deleteById(uid);
    }
    public Users findById(Integer uid){
        return userDao.findById(uid).orElse(null);
    }

    public Users findUser(Integer uid){
        return userDao.getById(uid);
    }

    public List<Users> findAll() {
        return userDao.findAll();
    }

}
